<template>
  <el-dialog :close-on-click-modal='false' v-drag :title="record.rule_id ? $t('编辑') : $t('添加')" append-to-body :v-if="dialogVisible" :visible.sync="dialogVisible" width="580px" top="5vh" @close='close'>
    <div class="dialogContentBoxMaxHeight90">
      <el-form ref="form" :inline="true" :model="record" label-width="160px" :rules="rules" label-position="left" style="margin:0 30px;">
        <el-form-item :label="$t('协议名称')" class="modbusForm" prop="proto">
          <span style="color:#999;">{{ rule[record.proto] }}</span>
        </el-form-item>
        <el-form-item :label="$t('类型')" prop="operate_type">
          <el-radio-group v-model="record.operate_type" @change="operateTypeChange" :disabled='record.rule_id !== null'>
            <el-radio label="0" class="deepfilts">{{$t('深度过滤')}}</el-radio>
            <el-radio label="1" class="portect">{{$t('扫描防护')}}</el-radio>
            <el-radio label="2" class="operate">{{$t('关联操作')}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item :label="$t('动作')" class="modbusForm" prop="action">
          <el-select v-model="record.action" class="modbusLength" ref="action" size='small' filterable>
            <el-option v-for="(value, key) in actionList[record.operate_type]" :key="key" :label="$t(value)" :value="key">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- --------------------------------深度过滤--------------------------------- -->
        <div v-if="record.operate_type == '0'">
          <el-form-item :label="$t('功能码')" class="modbusForm" v-if="record.operate_type == '0'" prop="func">
            <el-select v-model="record.func" size='small' ref="recordFunc" class="modbusLength" filterable @change="funcChange">
              <el-option v-for="(value, key) in funcList" :key="key" :label="$t(value)" :value="key">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('匹配范围')" class="modbusForm" prop="action">
            <el-radio-group v-model="record.accept_range">
              <el-radio label="all" class="all">{{$t('所有')}}</el-radio>
              <el-radio label="single" class="single">{{$t('单个')}}</el-radio>
            </el-radio-group>
          </el-form-item>
          <div v-if="record.accept_range === 'single'">
            <el-form-item :label="$t('读寄存器起始地址')" v-if="['1', '2', '3', '4', '20', '23', '24'].includes(record.func)" class="modbusForm" prop="reg_addr_read_start" key="reg_addr_read_start">
              <el-input v-emoji v-model="record.reg_addr_read_start" ref="record" class="modbusLength" size='small'></el-input>
            </el-form-item>
            <el-form-item :label="$t('读寄存器结束地址')" v-if="['1', '2', '3', '4', '20', '23', '24'].includes(record.func)" class="modbusForm" prop="reg_addr_read_end" key="reg_addr_read_end">
              <el-input v-emoji v-model="record.reg_addr_read_end" class="modbusLength" ref="end" size='small'></el-input>
            </el-form-item>
            <el-form-item :label="$t('写寄存器起始地址')" v-if="['5', '6', '15', '16', '21', '23'].includes(record.func)" class="modbusForm" prop="reg_addr_write_start" key="reg_addr_write_start">
              <el-input v-emoji v-model="record.reg_addr_write_start" ref="writeStart" class="modbusLength" size='small'></el-input>
            </el-form-item>
            <el-form-item :label="$t('写寄存器结束地址')" v-if="['5', '6', '15', '16', '21', '23'].includes(record.func)" class="modbusForm" prop="reg_addr_write_end" key="reg_addr_write_end">
              <el-input v-emoji v-model="record.reg_addr_write_end" ref="writeEnd" class="modbusLength" size='small'></el-input>
            </el-form-item>
            <el-form-item :label="$t('设备地址')" class="modbusForm" prop="device_address" key="device_address">
              <el-input v-emoji v-model="record.device_address" ref="device" class="modbusLength" size='small'></el-input>
            </el-form-item>
            <el-form-item :label="$t('文件编号')" v-if="['17', '20', '21'].includes(record.func)" class="modbusForm" prop="file_num" key="file_num">
              <el-input v-emoji v-model="record.file_num" ref="file" class="modbusLength" size='small'></el-input>
            </el-form-item>
            <el-form-item :label="$t('寄存器值范围')" v-if="['5', '6', '15', '16', '23'].includes(record.func)" style="margin-right:0" prop="register_value_range_start" key="register_value_range_start">
              <el-select v-model="record.register_value_range_start" ref="rangeStart" class="modbusLength" @change="registerRangeChange" v-if="['5', '15'].includes(record.func)" size='small' filterable>
                <el-option v-for="(value, key) in registerValueRangeSelectList" :key="key" :label="$t(value)" :value="key">
                </el-option>
              </el-select>
              <el-input v-emoji v-model="record.register_value_range_start" ref="registerRangeChangeStart" @change="registerRangeChange" v-if="['6', '16', '23'].includes(record.func)" style="width:117px" size='small'></el-input>
            </el-form-item>
            <el-form-item label="" v-if="['6', '16', '23'].includes(record.func)" style="margin-right:0">~</el-form-item>
            <el-form-item label-width="0" v-if="['6', '16', '23'].includes(record.func)" prop="register_value_range_end" key="register_value_range_end">
              <el-input v-emoji v-model="record.register_value_range_end" ref="registerRangeChangeEnd" @change="registerRangeChange" style="width:117px" size='small'></el-input>
            </el-form-item>
          </div>
        </div>
        <!-- --------------------------------扫描防护--------------------------------- -->
        <div v-if="record.operate_type == '1'">
          <el-form-item :label="$t('允许服务器返回错误的次数')" class="modbusForm" prop="error_count" key="error_count">
            <el-input v-emoji v-model="record.error_count" ref="errorCount" class="modbusLength" size='small'></el-input>
          </el-form-item>
        </div>

        <!-- --------------------------------关联操作--------------------------------- -->
        <div v-if="record.operate_type == '2'">
          <el-form-item :label="$t('写操作功能码')" class="modbusForm" prop="write_reg_func">
            <el-select v-model="record.write_reg_func" ref="writeReg" class="modbusLength" size='small' filterable>
              <el-option v-for="(value, key) in writeRegFuncList" :key="key" :label="$t(value)" :value="key">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('写操作设备编号')" class="modbusForm" prop="write_device_address" key="write_device_address">
            <el-input v-emoji v-model="record.write_device_address" ref="address" class="modbusLength" size='small'></el-input>
          </el-form-item>
          <el-form-item :label="$t('写寄存器地址')" class="modbusForm" prop="write_addr" key="write_addr">
            <el-input v-emoji v-model="record.write_addr" ref="addr" class="modbusLength" size='small'></el-input>
          </el-form-item>

          <el-form-item :label="$t('读功能码')" class="modbusForm" prop="connect_read_reg_func">
            <el-select v-model="record.connect_read_reg_func" ref="regFunc" class="modbusLength" size='small' filterable @change="connectReadRegFuncChange">
              <el-option v-for="(value, key) in connectReadRegFuncList" :key="key" :label="$t(value)" :value="key">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('读设备编号')" class="modbusForm" prop="connect_read_device_address" key="connect_read_device_address">
            <el-input v-emoji v-model="record.connect_read_device_address" ref="devices" class="modbusLength" size='small'></el-input>
          </el-form-item>
          <el-form-item :label="$t('读寄存器地址')" key="connect_read_addr" class="modbusForm" prop="connect_read_addr">
            <el-input v-emoji v-model="record.connect_read_addr" ref="read" class="modbusLength" size='small'></el-input>
          </el-form-item>
          <el-form-item :label="$t('读设备安全范围')" prop="connect_read_value_max" v-if="connectReadValueMaxList.includes(record.connect_read_reg_func)" key="connect_read_value_max" style="margin-right:0;">
            <el-select v-model="record.connect_read_value_max" ref="valueMax" class="modbusLength" size='small' filterable>
              <el-option v-for="(value, key) in connectReadValueSelectList" :key="key" :label="$t(value)" :value="key">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('读设备安全范围')" prop="connect_read_value_min" v-if="!connectReadValueMaxList.includes(record.connect_read_reg_func)" key="connect_read_value_min" style="margin-right:0">
            <el-input v-emoji v-model="record.connect_read_value_min" ref="recordConnect" style="width:117px" size='small'></el-input>
          </el-form-item>
          <el-form-item label="" v-if="!connectReadValueMaxList.includes(record.connect_read_reg_func)" style="margin-right:0">~</el-form-item>
          <el-form-item label-width="0" v-if="!connectReadValueMaxList.includes(record.connect_read_reg_func)" prop="connect_read_value_max" key="connect_read_value_max">
            <el-input v-emoji v-model="record.connect_read_value_max" ref="recordMax" style="width:117px" size='small'></el-input>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submit" class="innerAddSubmit">{{$t('确 定')}}</el-button>
      <el-button @click="close" class="innerAddClose">{{$t('取 消')}}</el-button>
    </span>

  </el-dialog>
</template>
<script>
import ruleArray from '../../ruleArray'
import { inputClass, selectClass } from '@/utils/input-class.js'
export default {
  name: 'ModbusDialog',
  data () {
    var validateRegAddr = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else {
        callback()
      }
    }
    var validateRegAddrRead = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else if (this.record.reg_addr_read_start && this.record.reg_addr_read_end && (Number(this.record.reg_addr_read_start) > Number(this.record.reg_addr_read_end))) {
        callback(new Error(this.$t('起始地址必须小于结束地址')))
      } else {
        this.chearRule('reg_addr_read_start')
        this.chearRule('reg_addr_read_end')
        callback()
      }
    }
    var validateRegAddrWrite = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else if (this.record.reg_addr_write_start && this.record.reg_addr_write_end && (Number(this.record.reg_addr_write_start) > Number(this.record.reg_addr_write_end))) {
        callback(new Error(this.$t('起始地址必须小于结束地址')))
      } else {
        this.chearRule('reg_addr_write_start')
        this.chearRule('reg_addr_write_end')
        callback()
      }
    }
    var validateName = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else {
        callback()
      }
    }
    var validateDeviceAddress = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 256) {
        callback(new Error(this.$t('输入范围0~256')))
      } else {
        callback()
      }
    }
    var validateRegisterStart = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else if (['6', '16', '23'].includes(this.record.func) && this.record.register_value_range_start && this.record.register_value_range_end && (Number(this.record.register_value_range_start) > Number(this.record.register_value_range_end))) {
        callback(new Error(this.$t('不能大于最大值')))
      } else {
        this.chearRule('register_value_range_start')
        this.chearRule('register_value_range_end')
        callback()
      }
    }
    var validateRegisterEnd = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else if (this.record.register_value_range_start && this.record.register_value_range_end && (Number(this.record.register_value_range_start) > Number(this.record.register_value_range_end))) {
        callback(new Error(this.$t('不能小于最小值')))
      } else {
        this.chearRule('register_value_range_start')
        this.chearRule('register_value_range_end')
        callback()
      }
    }
    var validateConnectMin = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else if (this.record.connect_read_value_min && this.record.connect_read_value_max && (Number(this.record.connect_read_value_min) > Number(this.record.connect_read_value_max))) {
        callback(new Error(this.$t('不能大于最大值')))
      } else {
        this.chearRule('connect_read_value_min')
        this.chearRule('connect_read_value_max')
        callback()
      }
    }
    var validateConnectMax = (rule, value, callback) => {
      if (String(value).trim() === '') {
        callback(new Error(this.$t('不能为空')))
      } else if (isNaN(Number(value))) {
        callback(new Error(this.$t('只能输入数字')))
      } else if (!this.isInteger(value)) {
        callback(new Error(this.$t('只能输入整数')))
      } else if (Number(value) < 0 || Number(value) > 65535) {
        callback(new Error(this.$t('输入范围0~65535')))
      } else if (this.record.connect_read_value_min && this.record.connect_read_value_max && (Number(this.record.connect_read_value_min) > Number(this.record.connect_read_value_max))) {
        callback(new Error(this.$t('不能小于最小值')))
      } else {
        this.chearRule('connect_read_value_min')
        this.chearRule('connect_read_value_max')
        callback()
      }
    }
    return {
      dialogVisible: false,
      record: {
        operate_type: '0',
        action: 'accept',
        rule_id: null,
        accept_range: 'all',
        device_address: '',
        error_count: '',
        file_num: '',
        func: '1',
        proto: 'modbus',
        reg_addr_read_end: '',
        reg_addr_read_start: '',
        reg_addr_write_end: '',
        reg_addr_write_start: '',
        register_value_range_end: '',
        register_value_range_start: '',
        register_value_range: '',
        connect_read_addr: '',
        connect_read_device_address: '',
        connect_read_reg_func: '1',
        connect_read_value_max: '0',
        connect_read_value_min: '',
        write_addr: '',
        write_device_address: '',
        write_reg_func: '5'
      },
      recordCopy: {
        operate_type: '0',
        action: 'accept',
        rule_id: null,
        accept_range: 'all',
        device_address: '0',
        error_count: '',
        file_num: '0',
        func: '1',
        proto: 'modbus',
        reg_addr_read_end: '0',
        reg_addr_read_start: '0',
        reg_addr_write_end: '0',
        reg_addr_write_start: '0',
        register_value_range_end: '',
        register_value_range_start: '',
        register_value_range: '',
        connect_read_addr: '',
        connect_read_device_address: '',
        connect_read_reg_func: '1',
        connect_read_value_max: '0',
        connect_read_value_min: '',
        write_addr: '',
        write_device_address: '',
        write_reg_func: '5'
      },
      rule: ruleArray.ruleShow,
      funcList: ruleArray.funcList,
      rangeList: ruleArray.rangeList,
      actionList: {
        '0': { 'accept': '允许', 'alert': '告警' },
        '1': { 'alert': '告警', 'deny': '阻断' },
        // '1': { 'alert': '告警' },
        '2': { 'accept': '允许', 'alert': '告警' }
      },
      writeRegFuncList: ruleArray.writeRegFuncList,
      connectReadRegFuncList: ruleArray.connectReadRegFuncList,
      connectReadValueSelectList: {
        '0': '关',
        '1': '开'
      },
      registerValueRangeSelectList: {
        '0': '关',
        '1': '开',
        '2': '开关'
      },
      connectReadValueMaxList: ['1', '2'],
      registerValueRangeStartList: ['5', '15'],
      rules: {
        // modbus
        reg_addr_read_start: [{ required: false, validator: validateRegAddrRead, trigger: 'blur' }],
        reg_addr_read_end: [{ required: false, validator: validateRegAddrRead, trigger: 'blur' }],
        reg_addr_write_start: [{ required: false, validator: validateRegAddrWrite, trigger: 'blur' }],
        reg_addr_write_end: [{ required: false, validator: validateRegAddrWrite, trigger: 'blur' }],
        error_count: [{ required: false, validator: validateName, trigger: 'blur' }],
        file_num: [{ required: false, validator: validateName, trigger: 'blur' }],
        device_address: [{ required: false, validator: validateDeviceAddress, trigger: 'blur' }],
        register_value_range_start: [{ required: false, validator: validateRegisterStart, trigger: 'blur' }],
        register_value_range_end: [{ required: false, validator: validateRegisterEnd, trigger: 'blur' }],
        // modbus_connect
        write_device_address: [{ required: false, validator: validateDeviceAddress, trigger: 'blur' }],
        write_addr: [{ required: false, validator: validateRegAddr, trigger: 'blur' }],
        connect_read_device_address: [{ required: false, validator: validateDeviceAddress, trigger: 'blur' }],
        connect_read_addr: [{ required: false, validator: validateName, trigger: 'blur' }],
        connect_read_value_max: [{ required: false, validator: validateConnectMax, trigger: 'blur' }],
        connect_read_value_min: [{ required: false, validator: validateConnectMin, trigger: 'blur' }]
      }
    }
  },
  computed: {
    change () {
      const { accept_range, operate_type, connect_read_reg_func, func } = this.record
      return { operate_type, accept_range, connect_read_reg_func, func }
    }
  },
  watch: {
    change: {
      handler (newValue) {
        if (newValue.operate_type === '0') {
          if (newValue.accept_range === 'single') {
            this.$nextTick(() => {
              const data = ['device']
              inputClass(this.$refs, data)
            })
            if (['1', '2', '3', '4', '20', '23', '24'].includes(newValue.func)) {
              this.$nextTick(() => {
                const data = ['record', 'end']
                inputClass(this.$refs, data)
              })
            }
            if (['5', '6', '15', '16', '21', '23'].includes(newValue.func)) {
              this.$nextTick(() => {
                const data = ['writeStart', 'writeEnd']
                inputClass(this.$refs, data)
              })
              if (['5', '15'].includes(newValue.func)) {
                this.$nextTick(() => {
                  const selectData = ['rangeStart']
                  selectClass(this.$refs, selectData)
                })
              } else if (['6', '16', '23'].includes(newValue.func)) {
                this.$nextTick(() => {
                  const data = ['registerRangeChangeStart', 'registerRangeChangeEnd']
                  inputClass(this.$refs, data)
                })
              }
            }
            if (['17', '20', '21'].includes(newValue.func)) {
              this.$nextTick(() => {
                const data = ['file']
                inputClass(this.$refs, data)
              })
            }
          }
        } else if (newValue.operate_type === '1') {
          this.$nextTick(() => {
            const data = ['errorCount']
            inputClass(this.$refs, data)
          })
        } else if (newValue.operate_type === '2') {
          this.$nextTick(() => {
            const data = ['address', 'addr', 'devices', 'read']
            const selectData = ['writeReg', 'regFunc']
            inputClass(this.$refs, data)
            selectClass(this.$refs, selectData)
          })
          if (this.connectReadValueMaxList.includes(newValue.connect_read_reg_func)) {
            this.$nextTick(() => {
              const selectData = ['valueMax']
              selectClass(this.$refs, selectData)
            })
          } else if (!this.connectReadValueMaxList.includes(newValue.connect_read_reg_func)) {
            this.$nextTick(() => {
              const data = ['recordConnect', 'recordMax']
              inputClass(this.$refs, data)
            })
          }
        }
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    init (data) {
      this.dialogVisible = true
      this.$nextTick(() => {
        const selectData = ['action', 'recordFunc']
        selectClass(this.$refs, selectData)
      })
      if (data) {
        this.record = Object.assign(this.record, data)
        this.record.register_value_range_start = this.record.register_value_range.split('-')[0] || ''
        this.record.register_value_range_end = this.record.register_value_range.split('-')[1] || ''
      }
    },
    submit () {
      this.$refs.form.validate((valid) => {
        if (valid) {
          var formData = JSON.parse(JSON.stringify(this.record))
          this.$emit('addConfigRuleMap', formData)
        }
      })
    },
    close () {
      this.dialogVisible = false
      this.$emit('childrenClose')
      this.record = Object.assign({}, this.recordCopy)
      this.$refs.form.resetFields()
    },
    operateTypeChange (val) {
      this.record.action = val === '1' ? 'alert' : 'accept'
      if (val === '2') {
        this.record.proto = 'modbus_connect'
      } else {
        this.record.proto = 'modbus'
      }
    },
    funcChange (val) {
      this.record.reg_addr_read_start = ''
      this.record.reg_addr_read_end = ''
      this.record.reg_addr_write_start = ''
      this.record.reg_addr_write_end = ''
      this.record.device_address = ''
      this.record.file_num = ''

      this.record.register_value_range_start = this.registerValueRangeStartList.includes(val) ? '0' : ''
      this.record.register_value_range_end = this.registerValueRangeStartList.includes(val) ? '0' : ''
      this.registerRangeChange()
      this.$refs.form.clearValidate(['register_value_range_start', 'register_value_range_end', 'reg_addr_read_start', 'reg_addr_read_end', 'reg_addr_write_start', 'reg_addr_write_end', 'device_address', 'file_num'])
    },
    connectReadRegFuncChange (val) {
      this.record.connect_read_value_max = this.connectReadValueMaxList.includes(val) ? '0' : ''
      this.record.connect_read_value_min = this.connectReadValueMaxList.includes(val) ? '0' : ''
      this.$refs.form.clearValidate(['connect_read_value_max', 'connect_read_value_min'])
    },
    registerRangeChange () {
      if (['5', '15'].includes(this.record.func)) {
        this.record.register_value_range = this.record.register_value_range_start + '-' + 0
      } else if (this.record.register_value_range_start && this.record.register_value_range_end) {
        this.record.register_value_range = this.record.register_value_range_start + '-' + this.record.register_value_range_end
      } else if (this.record.register_value_range_start) {
        this.record.register_value_range = this.record.register_value_range_start
      } else if (this.record.register_value_range_end) {
        this.record.register_value_range = this.record.register_value_range_end
      }
    },
    isInteger (value) {
      return (!isNaN(value) && (parseInt(value).toString().length === String(Number(value)).length))
    },
    chearRule (name) {
      if (!isNaN(Number(this.record[name])) && this.isInteger(this.record[name]) && (Number(this.record[name]) >= 0 && Number(this.record[name]) <= 65535)) {
        this.$refs['form'].clearValidate([name])
      }
    }
  }
}
</script>
<style>
.modbusLength {
  width: 250px;
}
</style>
